package cluedo;


import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Vector;

import javax.swing.ImageIcon;


/** Carta stanza*/
public class Room extends Card {


	private static final long serialVersionUID = 6530727681041085566L;
	
	/**
	 * I possibili nomi delle stanze associati ai path
	 */
	public final static HashMap<String,String> rooms = new HashMap<String,String>();
	static {
        rooms.put("Kitchen", "/img/kitchen.jpg");
        rooms.put("Dining Room", "/img/diningroom.jpg");
        rooms.put("Lounge", "/img/lounge.jpg");
        rooms.put("BallRoom", "/img/ballroom.jpg");
        rooms.put("Hall", "/img/hall.jpg");
        rooms.put("Conservatory", "/img/conservatory.jpg");
        rooms.put("Billiard Room", "/img/billiardroom.jpg");
        rooms.put("Library", "/img/library.jpg");
        rooms.put("Study", "/img/study.jpg");
    }
	
	
	/**
	 * Costruttore carta stanza
	 * @param name il nome della stanza
	 */
	public Room(String name){
		
		if(rooms.containsKey(name)){
			this.name=name;
			setImage();
		}
		else
        	System.err.println("Room: Il nome della stanza non e' valido");
		
	}	
	
	@Override
	protected void setImage(){
		
		cardImage = new ImageIcon(Room.class.getResource(rooms.get(this.name))); 
	}

	/**
	 * Restituisce una lista di tutte le carte stanza
	 * @return vedi descrizione
	 */
	public static List<Room> allRooms() {
		
		List<Room> list= new Vector<Room>(rooms.size());
		
		for(Map.Entry<String, String> entry : rooms.entrySet()){
			list.add(new Room(entry.getKey()));
		}
		
		return list;
	}
}
